package com.wl.application.common.all;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author wl
 * @version 1.0
 * @date 2022/6/16
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {


    private Integer code;

    private String msg;

    private Object data;


    public static Result ok(){
        return new Result(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(), null);
    }
    public static Result ok(Object data){
        return new Result(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(), data);
    }
    public static Result ok(String msg,Object data){
        return new Result(ResultEnum.SUCCESS.getCode(),msg, data);
    }
    public static Result ok(String msg){
        return new Result(ResultEnum.SUCCESS.getCode(),msg, null);
    }

    public static Result fail(){
        return new Result(ResultEnum.FAIL.getCode(),ResultEnum.FAIL.getMsg(), null);
    }
    public static Result fail(Object data){
        return new Result(ResultEnum.FAIL.getCode(),ResultEnum.FAIL.getMsg(), data);
    }
    public static Result fail(String msg,Object data){
        return new Result(ResultEnum.FAIL.getCode(),msg, data);
    }


    public static Result fault(){
        return new Result(ResultEnum.FAULT.getCode(),ResultEnum.FAULT.getMsg(), null);
    }
    public static Result fault(Object data){
        return new Result(ResultEnum.FAULT.getCode(),ResultEnum.FAULT.getMsg(), data);
    }
    public static Result fault(String msg,Object data){
        return new Result(ResultEnum.FAULT.getCode(),msg, data);
    }
    public static Result fault(Integer code,String msg,Object...data){
        return new Result(code,msg, data);
    }
    public static Result fault(String msg){
        return new Result(ResultEnum.FAULT.getCode(), msg,null);
    }

    public static Result error(){
        return new Result(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMsg(), null);
    }
    public static Result error(Object data){
        return new Result(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMsg(), data);
    }
    public static Result error(String msg,Object data){
        return new Result(ResultEnum.ERROR.getCode(),msg, data);
    }

}
